package textprocessing.nlpanalysis.constituent;

import edu.stanford.nlp.trees.Tree;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by common on 2017/4/8.
 */
public class SCITree {


    public enum NodeType {
        SUB, ENUM, CONC, LEAF
    }


    public static class SCITreeNode {

        // 原始节点
        public Tree originalNode;

        // 节点类型
        public NodeType nodeType;

        // 叶子节点
        public Boolean isLeaf;

        // 头节点，对于从句有用
        public SCITreeNode headNode;

        // 子节点
        public List<SCITreeNode> childs;

        public String content;

        // 包含的context集合
        public List<String> contexts;

        public List<ContextItem> contextItems;



        public SCITreeNode(){
            originalNode = null;
            nodeType = NodeType.CONC;
            isLeaf = Boolean.FALSE;
            headNode = null;
            childs = new ArrayList<>();
            contexts = new ArrayList<>();
            content = "";
            contextItems = new ArrayList<>();
        }

    }

    public SCITreeNode root;

    public SCITree(){
        this.root = new SCITreeNode();
    }


    /*
    ********************************************
    * STATIC HELPER METHOD
     */
    public static void traversal_print(SCITree.SCITreeNode root, String indent){
        System.out.println(indent + "[type=" + root.nodeType + " ]" + "[content= " + root.content + " ]" );
        for(SCITree.SCITreeNode child : root.childs){
            traversal_print(child, indent + "  ");
        }
    }

}
